package com.yc.resfoods.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName ServiceController
 * @since: 2023/8/24 11:29
 * @auth: kirito
 * @description:
 **/
@RestController
@RequestMapping("service")
@RefreshScope //监听刷新
//@AutoConfiguration 可以在main方法配置监听全部
public class ServiceController {

    @Value("${res.pattern.dateformat}")
    private String dateformate;
    @RequestMapping("getTime")
    public Map<String,Object> nowTime() {
        Map<String,Object> map = new HashMap<>();
        Date date = new Date();
        DateFormat df = new SimpleDateFormat(dateformate);

        map.put("code", 1);
        map.put("obj",df.format(date));
        return map;
    }
}
